package com.macro.mall.controller;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.BmsDictDataParam;
import com.macro.mall.dto.BmsGuidePointParam;
import com.macro.mall.dto.BmsRecruitmentInformationParam;
import com.macro.mall.model.BmsDictData;
import com.macro.mall.model.BmsGuidePoint;
import com.macro.mall.model.BmsRecruitmentInformation;
import com.macro.mall.service.BmsDictDataService;
import com.macro.mall.service.BmsGuidePointService;
import com.macro.mall.service.BmsRecruitmentInformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 招聘信息ontroller
 * Created by macro on 2018/4/26.
 */
@Controller
@Api(tags = "BmsRecruitmentInformationController")
@Tag(name = "BmsRecruitmentInformationController", description = "招募信息管理")
@RequestMapping("/information")
public class BmsRecruitmentInformationController {
    @Autowired
    private BmsRecruitmentInformationService bmsRecruitmentInformationService;

    @ApiOperation("添加招募信息")
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> create(@RequestBody BmsRecruitmentInformationParam bmsRecruitmentInformationParam) {
        int count = bmsRecruitmentInformationService.create(bmsRecruitmentInformationParam);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }


    @ApiOperation("修改招募信息")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> update(@RequestBody BmsRecruitmentInformationParam bmsRecruitmentInformationParam) {
        int count = bmsRecruitmentInformationService.update(bmsRecruitmentInformationParam);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }
    @ApiOperation("分页查询招募信息")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsRecruitmentInformation>> getList(@RequestBody BmsRecruitmentInformationParam bmsRecruitmentInformationParam) {
        List<BmsRecruitmentInformation> bmsRecruitmentInformationList = bmsRecruitmentInformationService.getList(bmsRecruitmentInformationParam);
        return CommonResult.success(CommonPage.restPage(bmsRecruitmentInformationList));
    }
//
    @ApiOperation("根据id获取招募信息")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsRecruitmentInformation> getItem(@PathVariable Long id) {
        BmsRecruitmentInformation bmsRecruitmentInformation = bmsRecruitmentInformationService.getDetail(id);
        return CommonResult.success(bmsRecruitmentInformation);
    }
//
    @ApiOperation("删除招募信息")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> delete(@RequestBody List<Long> ids) {
        int count = bmsRecruitmentInformationService.delete(ids);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }


}
